package com.dylan.jetcache.controller.user;

import com.dylan.jetcache.entity.User;
import com.dylan.jetcache.service.user.UserService;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;

/**
 * @author zhangshaojian
 * @date 2022/7/8 14:27
 */
@RestController
@RequestMapping("user")
public class UserController {

    @Resource
    private UserService userService;

    @GetMapping
    public List<User> findAll() {
        return userService.findAll();
    }

    @GetMapping("/{name}")
    public void save(@PathVariable String name) {
        User user = new User().setName(name).setAge(4);
        userService.save(user);
    }
}
